package com.bachongLightNovel.system.mapper;
import com.bachongLightNovel.model.dto.system.SystemUserPageDto;
import com.bachongLightNovel.model.pojo.system.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SystemUserMapper{
    //根据用户名查询用户信息
    @Select("SELECT * from user where username=#{userName}")
    User selectByName(String userName);

    //根据id获取用户信息
    @Select("select * from user where id=#{userId}")
    User selectById(Long id);

    //查询记录总数
    @Select("select count(*) from user")
    Long count();

    //根据查询条件，查询数据
    List<User> selectByQuery(Integer current, Integer size, SystemUserPageDto dto);

    //将user中的数据插入到数据表当中
    @Insert("insert into user (username, password, avatar, phone)" +
            " values (#{username},#{password},#{avatar},#{phone});")
    void insert(User user);

    //根据id修改数据
    void update(User user);

    //根据id删除数据
    @Delete("delete from user where id=#{id};")
    void deleteById(Long id);

    //根据用户名模糊查询对应的用户id
    List<Long> selectIdsByUsername(String auditUser);

    //根据手机号查询数据
    User selectByPhone(String phone);
}
